package com.googlecode.framework.web.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.googlecode.framework.web.pagination.AbstractWebPagination;
import com.googlecode.framework.web.pagination.PaginationConstants;

public class PaginationTag extends TagSupport {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -1089993622892445414L;
    
    /**
     * 当翻页和排序时，请求中那些参数不会被传递下去
     */
    private String excludedParams;
    
    @Override
    public int doEndTag() throws JspException {
        AbstractWebPagination awp = (AbstractWebPagination) pageContext.getRequest().getAttribute(PaginationConstants.DEFAULT_PAGINATION_NAME);
        if (awp != null) {
            try {
                pageContext.getOut().write(awp.getHtmlPageToolbar());
            } catch (Exception e) {
                throw new JspException(e);
            }
        }

        return super.doEndTag();
    }

    public void setExcludedParams(String excludedParams) {
        this.excludedParams = excludedParams;
    }
}
